﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:sys="javascript:Sys"
  xmlns:watermark="javascript:Sys.Extended.UI.TextBoxWatermarkBehavior"
  xmlns:maskededit="javascript:Sys.Extended.UI.MaskedEditBehavior"
  xmlns:ajax="urn:AjaxExtensions"
  xmlns:childAction="urn:ChildActionExtensions"
  xmlns:link="urn:LinkExtensions"
  xmlns:mvc="urn:HtmlHelper"
  xmlns:validation="urn:ValidationExtensions"
  xmlns:renderPartial="urn:RenderPartialExtensions"
  xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  xmlns:xs="urn:dummy"
  xmlns:output="urn:output"
  xmlns:urlHelper="urn:UrlHelperExtensions"
  xmlns:form="urn:FormExtensions"
  exclude-result-prefixes="msxsl sys watermark maskededit"
                  xmlns:eval="urn:eval">

  <!-- customized template processing here... -->
  <xsl:template match="debug">
    <div class="debug">
    Template:<br />
    <textarea class="debugBox">
      <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
      <xsl:copy-of select="/" />
      <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
    </textarea><br />
    Model:<br />
    <textarea class="debugBox">
      <xs:copy-of select="/" />
    </textarea>
    </div>
  </xsl:template>
  <xsl:template match="wizardNav">
    <xsl:variable name="name" select="@name" />
    <xsl:call-template name="wizardNav">
      <xsl:with-param name="name" select="$name" />
    </xsl:call-template>
  </xsl:template>
  <xsl:template name="wizardNav">
    <xsl:param name="name" />
    <div class="nav">
      <form style="display:inline">
        <xsl:attribute name="action"  xmlns:s="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
          <xsl:variable name="prev" select="document('~/Views/Home/Web.sitemap')/s:siteMap/s:siteMapNode[@url='Home']/s:siteMapNode[following-sibling::*[1][@url=$name] or ($name='Home' and position()=last())]"/>
          <xsl:choose>
            <xsl:when test="$prev">
              <xsl:value-of select="concat('/home/',$prev/@url)" />
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="'/home/'" />
            </xsl:otherwise>
          </xsl:choose>
        </xsl:attribute>
        <input type="submit" value="Previous" accesskey="P" />
      </form>
      <form style="display:inline">
        <xsl:attribute name="action"  xmlns:s="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
          
          <xsl:variable name="next" select="document('~/Views/Home/Web.sitemap')/s:siteMap/s:siteMapNode[@url='Home']/s:siteMapNode[preceding-sibling::*[1][@url=$name] or ($name='Home' and position()=1)]" />
          <xsl:choose>
            <xsl:when test="$next">
              <xsl:value-of select="concat('/home/',$next/@url)" />
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="'/home/'" />
            </xsl:otherwise>
          </xsl:choose>
          
        </xsl:attribute>
        <input type="submit" value="Next" accesskey="N" />
      </form>
    </div>
  </xsl:template>
  <xsl:template match="pageContent">
    <table class="content">
      <tr>
        <td class="content">
          <xsl:apply-templates select="*" />
        </td>
      </tr>
    </table>
  </xsl:template>
</xsl:stylesheet>
